﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiRasterImageBGRA32 : OdGiRasterImageParam
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiRasterImageBGRA32(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiRasterImageBGRA32_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiRasterImageBGRA32 obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiRasterImageBGRA32()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiRasterImageBGRA32(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public static OdGiRasterImage createObject(OdGiImageBGRA32 pImage, OdGiRasterImage.TransparencyMode transparencyMode)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiRasterImageBGRA32_createObject__SWIG_0(OdGiImageBGRA32.getCPtr(pImage), (int)transparencyMode);
			OdGiRasterImage result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiRasterImage)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiRasterImage)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiRasterImage)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiRasterImage createObject(OdGiImageBGRA32 pImage)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiRasterImageBGRA32_createObject__SWIG_1(OdGiImageBGRA32.getCPtr(pImage));
			OdGiRasterImage result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiRasterImage)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiRasterImage)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiRasterImage)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint pixelWidth()
		{
			uint result = GlobalsPINVOKE.OdGiRasterImageBGRA32_pixelWidth(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint pixelHeight()
		{
			uint result = GlobalsPINVOKE.OdGiRasterImageBGRA32_pixelHeight(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint colorDepth()
		{
			uint result = GlobalsPINVOKE.OdGiRasterImageBGRA32_colorDepth(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint numColors()
		{
			uint result = GlobalsPINVOKE.OdGiRasterImageBGRA32_numColors(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint color(uint colorIndex)
		{
			uint result = GlobalsPINVOKE.OdGiRasterImageBGRA32_color(this.swigCPtr, colorIndex);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint paletteDataSize()
		{
			uint result = GlobalsPINVOKE.OdGiRasterImageBGRA32_paletteDataSize(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void paletteData(byte[] bytes)
		{
			GlobalsPINVOKE.OdGiRasterImageBGRA32_paletteData(this.swigCPtr, Teigha.Core.Helpers.MarshalbyteFixedArray(bytes));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual uint scanLineSize()
		{
			uint result = GlobalsPINVOKE.OdGiRasterImageBGRA32_scanLineSize(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual byte[] scanLines()
		{
			byte[] result = Teigha.Core.Helpers.UnMarshalbyteFixedArray(GlobalsPINVOKE.OdGiRasterImageBGRA32_scanLines__SWIG_0(this.swigCPtr));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void scanLines(ref byte[] scnLines, uint firstScanline, uint numLines)
		{
			IntPtr intPtr = Teigha.Core.Helpers.MarshalbyteFixedArray(scnLines);
			try
			{
				GlobalsPINVOKE.OdGiRasterImageBGRA32_scanLines__SWIG_1(this.swigCPtr, intPtr, firstScanline, numLines);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
			finally
			{
				scnLines = Teigha.Core.Helpers.UnMarshalbyteFixedArray(intPtr);
				Marshal.FreeCoTaskMem(intPtr);
			}
		}

		public new virtual void scanLines(ref byte[] scnLines, uint firstScanline)
		{
			IntPtr intPtr = Teigha.Core.Helpers.MarshalbyteFixedArray(scnLines);
			try
			{
				GlobalsPINVOKE.OdGiRasterImageBGRA32_scanLines__SWIG_2(this.swigCPtr, intPtr, firstScanline);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
			finally
			{
				scnLines = Teigha.Core.Helpers.UnMarshalbyteFixedArray(intPtr);
				Marshal.FreeCoTaskMem(intPtr);
			}
		}

		public new virtual OdGiRasterImage.PixelFormatInfo pixelFormat()
		{
			OdGiRasterImage.PixelFormatInfo result = new OdGiRasterImage.PixelFormatInfo(GlobalsPINVOKE.OdGiRasterImageBGRA32_pixelFormat(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint scanLinesAlignment()
		{
			uint result = GlobalsPINVOKE.OdGiRasterImageBGRA32_scanLinesAlignment(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdGiRasterImage.Units defaultResolution(out double xPelsPerUnit, out double yPelsPerUnit)
		{
			OdGiRasterImage.Units result = (OdGiRasterImage.Units)GlobalsPINVOKE.OdGiRasterImageBGRA32_defaultResolution(this.swigCPtr, out xPelsPerUnit, out yPelsPerUnit);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint supportedParams()
		{
			uint result = GlobalsPINVOKE.OdGiRasterImageBGRA32_supportedParams(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdGiRasterImage.ImageSource imageSource()
		{
			OdGiRasterImage.ImageSource result = (OdGiRasterImage.ImageSource)GlobalsPINVOKE.OdGiRasterImageBGRA32_imageSource(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdGiRasterImage.TransparencyMode transparencyMode()
		{
			OdGiRasterImage.TransparencyMode result = (OdGiRasterImage.TransparencyMode)GlobalsPINVOKE.OdGiRasterImageBGRA32_transparencyMode(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void setTransparencyMode(OdGiRasterImage.TransparencyMode mode)
		{
			GlobalsPINVOKE.OdGiRasterImageBGRA32_setTransparencyMode(this.swigCPtr, (int)mode);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual OdRxObject clone()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiRasterImageBGRA32_clone(this.swigCPtr);
			OdRxObject result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void copyFrom(OdRxObject pSource)
		{
			GlobalsPINVOKE.OdGiRasterImageBGRA32_copyFrom(this.swigCPtr, OdRxObject.getCPtr(pSource));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
